package com.wzy.new_energy_car_platform.controller;


import com.wzy.new_energy_car_platform.common.ResultDto;
import com.wzy.new_energy_car_platform.model.SysUser;
import com.wzy.new_energy_car_platform.model.UserCar;
import com.wzy.new_energy_car_platform.service.SysUserService;
import com.wzy.new_energy_car_platform.service.UserCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wzy
 * @since 2024-02-06
 */
@RestController
@RequestMapping("/sys_user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private UserCarService userCarService;

    @PostMapping("/login")
    public ResultDto<?> login(@RequestBody SysUser sysUser){
        return sysUserService.login(sysUser);
    }

    @PostMapping("/register")
    public ResultDto<?> register(@RequestBody SysUser sysUser){
        return sysUserService.register(sysUser);
    }

    @GetMapping("/getUser")
    public ResultDto<?> getUser(String token){
        return sysUserService.getUser(token);
    }

    @GetMapping("/test")
    public ResultDto<?> test(){
        return ResultDto.ok("test");
    }

    @GetMapping("/getUserCar")
    public ResultDto<?> getUserCar(int userId){
         return userCarService.getUserCar(userId);
     }

    @PostMapping("/setUser")
    public ResultDto<?> setUser(@RequestBody SysUser sysUser){
         return sysUserService.setUser(sysUser);
     }

    @PostMapping("/uploadMyCar")
    public ResultDto<?> uploadMyCar(@RequestBody UserCar userCar){
        return userCarService.uploadMyCar(userCar);
    }

    @PostMapping("/uploadHeader")
    public  ResultDto<?> uploadHeader(@RequestBody Map<String, Object> map){
         return sysUserService.uploadHeader(map);
     }

     @PostMapping("/saveCarInfo")
    public  ResultDto<?> saveCarInfo(@RequestBody UserCar userCar){
          return  userCarService.saveCarInfo(userCar);
    }
}
